﻿using Batman.Authentication.Dtos;
using Microsoft.AspNetCore.Internal;

namespace Microsoft.AspNetCore.Builder
{
    public static class BatmanAuthBuilderExtension
    {
        /// <summary>
        /// 使用鉴权中间件
        /// </summary>
        /// <param name="app"></param>
        public static void UseBatmanAuthentication(this IApplicationBuilder app, string rmsUrl, string appCode)
        {
            ApplicationOptions.AppCode = appCode;
            ApplicationOptions.RmsUrl = rmsUrl;

            // UseEndpointRouting Is The Key. UseRouting Is Dotnet Core3 
            app.UseEndpointRouting();

            app.UseMiddleware<BatmanAuthentication>();
        }
    }
}
